package com.bot.nft.module.dc.api;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.dc.controller.DcNftInfoController;
import com.bot.nft.module.dc.domain.bo.DcNftQueryBo;
import com.bot.nft.module.dc.domain.vo.DcNftInfoVo;
import com.bot.nft.module.dc.service.IDcNftInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述: 藏品管理
 * 时间: 2023-11-27 19:49
 * 负责人: 任晓政
 **/
@RestController
@RequestMapping("/app/nft")
@CrossOrigin
public class AppDcNftInfoController extends DcNftInfoController {

    @Resource
    IDcNftInfoService dcNftService;

    //分页查询藏品信息
    @Override
    @RequestMapping("/{pageNo}/{pageSize}/select.do")
    public CommonResult<IPage> selectDcNft(@RequestBody DcNftQueryBo dcNftQueryBo, @PathVariable("pageNo") Integer pageNo, @PathVariable("pageSize") Integer pageSize) {
        IPage<DcNftInfoVo> dcNftInfoVoPageInfo = dcNftService.queryDcNftInfo(dcNftQueryBo.getType(), dcNftQueryBo.getKeyword(), dcNftQueryBo.getStatus(), pageNo, pageSize, dcNftQueryBo.getShow());
        CommonResult<IPage> commonResult = new CommonResult<>();
        commonResult.setMsg("查询成功");
        commonResult.setCode(200);
        commonResult.setData(dcNftInfoVoPageInfo);
        return commonResult;
    }

    //查看藏品信息
    @Override
    @RequestMapping("/{id}/getDcNft.do")
    public CommonResult<DcNftInfoVo> getDcNft(@PathVariable("id") String id) {
        //调用接口
        DcNftInfoVo dcNftInfo = dcNftService.getDcNftInfo(id);
        //查看中间表
        CommonResult<DcNftInfoVo> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcNftInfo)) {
            commonResult.setMsg("查看成功");
            commonResult.setCode(200);
            commonResult.setData(dcNftInfo);
        } else {
            commonResult.setMsg("查看失败");
            commonResult.setCode(500);
            commonResult.setData(null);
        }
        return commonResult;
    }

}
